package com.alan.shiro.api.token.helper;

import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;

/**
 * @Auther: Alan liu
 * @Date: 2018/12/13 10:53
 * @Description: 模拟缓存用户令牌操作接口
 */
@Component
public class UserTokenOperHelperImpl implements UserTokenOperHelper {

    /**
     * 简易保存
     */
    private Map<String,Object> cacheMap = new HashMap<>();

    @Override
    public String getUserToken(String userCode) {
        return (String) cacheMap.get(userCode);
    }

    @Override
    public void updateUserToken(String userCode, String token, long seconds) {
        cacheMap.put(userCode,token);
    }

    @Override
    public void deleteUserToken(String userCode) {
        cacheMap.remove(userCode);
    }

}
